package com.kaoshi.management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaoshi.management.pojo.XtSlideshow;
import com.kaoshi.management.pojo.XtSystemNotice;
import com.kaoshi.management.mapper.XtSystemNoticeMapper;
import com.kaoshi.management.service.XtSystemNoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-10-30
 */
@Service
public class XtSystemNoticeServiceImpl extends ServiceImpl<XtSystemNoticeMapper, XtSystemNotice> implements XtSystemNoticeService {

    @Autowired
    private XtSystemNoticeMapper xtSystemNoticeMapper;
    @Override
    public Page<XtSystemNotice> findAll(Integer current, Integer pageSize, XtSystemNotice xtSystemNotice) {
        Page<XtSystemNotice> page = new Page<>(current, pageSize);

        LambdaQueryWrapper<XtSystemNotice> queryWrapper = new LambdaQueryWrapper<>();
        if(xtSystemNotice.getTitle()!= null && !xtSystemNotice.getTitle().equals("")){
            queryWrapper.like(XtSystemNotice::getTitle, xtSystemNotice.getTitle());
        }
        if (xtSystemNotice.getStartDate() != null && xtSystemNotice.getEndDate() != null) {
            // 假设 XtSettingsInformationManagement 有一个获取日期的方法 getDate()
            queryWrapper.between(XtSystemNotice::getOperationTime, xtSystemNotice.getStartDate(), xtSystemNotice.getEndDate());
        }
        return xtSystemNoticeMapper.selectPage(page, queryWrapper);
    }
}
